package wyj;


import java.util.Scanner;



class Main51 {



    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        int m = in.nextInt();

        int sum = 0;

        int count = 1;

        if (n==1)

        {

            sum = 2;

        }

        for(int i=3;count<m;i++)

        {

            for(int j=2;j<i;j++)

            {

                if(i%j==0)

                {

                    break;

                }

                if(i-1==j)

                {

                    count++;

                    if(count>=n)

                    {

                        sum += i;

                    }

                }

            }

        }

        System.out.println(sum);

    }

}

